package com.example.shoppingmallspringboot.controller;

import com.example.shoppingmallspringboot.entity.Category;
import com.example.shoppingmallspringboot.service.CategoryService;
import com.example.shoppingmallspringboot.util.FwResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "CategoryController",description = "商品类别控制器")
@RestController //该注解等价于//@Controller+@ResponseBody
public class CategoryController {

    @Autowired
    CategoryService categoryService;
    //    获取全部商品类别
    @GetMapping("/category/list")
    @Operation(summary = "获取全部商品类别",description = "无参")
    public FwResult<List<Category>> getAllGoods(){
        List<Category> categories = categoryService.findAll();
        FwResult<List<Category>> result=FwResult.ok(categories);
        return result;
    }
}
